package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AdminLuckyCommand;
import com.ruoyi.system.service.IAdminLuckyCommandService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 玩法管理Controller
 *
 * @author ruoyi
 * @date 2021-06-03
 */
@RestController
@RequestMapping("/system/luckyCommand")
public class AdminLuckyCommandController extends BaseController
{
    @Autowired
    private IAdminLuckyCommandService adminLuckyCommandService;

    /**
     * 查询玩法管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:luckyCommand:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdminLuckyCommand adminLuckyCommand)
    {
        startPage();
        List<AdminLuckyCommand> list = adminLuckyCommandService.selectAdminLuckyCommandList(adminLuckyCommand);
        return getDataTable(list);
    }

    /**
     * 导出玩法管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:luckyCommand:export')")
    @Log(title = "玩法管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdminLuckyCommand adminLuckyCommand)
    {
        List<AdminLuckyCommand> list = adminLuckyCommandService.selectAdminLuckyCommandList(adminLuckyCommand);
        ExcelUtil<AdminLuckyCommand> util = new ExcelUtil<AdminLuckyCommand>(AdminLuckyCommand.class);
        return util.exportExcel(list, "luckyCommand");
    }

    /**
     * 获取玩法管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:luckyCommand:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adminLuckyCommandService.selectAdminLuckyCommandById(id));
    }

    /**
     * 新增玩法管理
     */
    @PreAuthorize("@ss.hasPermi('system:luckyCommand:add')")
    @Log(title = "玩法管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdminLuckyCommand adminLuckyCommand)
    {
        return toAjax(adminLuckyCommandService.insertAdminLuckyCommand(adminLuckyCommand));
    }

    /**
     * 修改玩法管理
     */
    @PreAuthorize("@ss.hasPermi('system:luckyCommand:edit')")
    @Log(title = "玩法管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdminLuckyCommand adminLuckyCommand)
    {
        return toAjax(adminLuckyCommandService.updateAdminLuckyCommand(adminLuckyCommand));
    }

    /**
     * 删除玩法管理
     */
    @PreAuthorize("@ss.hasPermi('system:luckyCommand:remove')")
    @Log(title = "玩法管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adminLuckyCommandService.deleteAdminLuckyCommandByIds(ids));
    }
}
